/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Renato
 */
@Entity
@Table(name = "promocao")
@NamedQueries({@NamedQuery(name = "Promocao.findAll", query = "SELECT p FROM Promocao p"), @NamedQuery(name = "Promocao.findById", query = "SELECT p FROM Promocao p WHERE p.id = :id"), @NamedQuery(name = "Promocao.findByValidade", query = "SELECT p FROM Promocao p WHERE p.validade = :validade")})
public class Promocao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "validade")
    @Temporal(TemporalType.TIMESTAMP)
    private Date validade;
    @Basic(optional = false)
    @Lob
    @Column(name = "descricao")
    private String descricao;
    @JoinTable(name = "cardapio_promocao", joinColumns = {@JoinColumn(name = "id_promocao", referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "id_cardapio", referencedColumnName = "id")})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<Cardapio> cardapioCollection;

    public Promocao() {
    }

    public Promocao(Integer id) {
        this.id = id;
    }

    public Promocao(Integer id, String descricao) {
        this.id = id;
        this.descricao = descricao;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getValidade() {
        return validade;
    }

    public void setValidade(Date validade) {
        this.validade = validade;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public List<Cardapio> getCardapioCollection() {
        return cardapioCollection;
    }

    public void setCardapioCollection(List<Cardapio> cardapioCollection) {
        this.cardapioCollection = cardapioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Promocao)) {
            return false;
        }
        Promocao other = (Promocao) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Promocao[id=" + id + "]";
    }

}
